<?php
namespace app\admin\controller;

class Adminlogin extends \think\Controller
{
    public function login(){
        if(isset($_POST['up'])){
            $email=$_POST['email'];
            $pwd=md5($_POST['pwd']);
            $res=db('admin_user')->where('email',$email)->find();         
            if($email==$res['email']&&$pwd==$res['pwd']){
                session('name', $res['name']);
                session('logintime', time());
                $this->success('登录成功!','admin/adminindex/index');
            }
            else{ 
                $this->error('登录失败');
            }
        }
        return $this->fetch('login');
    }
}